<?php
	$q = $_GET['q'];
	$my_data = $q;
	$mysqli=mysqli_connect('localhost','root','','cactus') or die("Database Error");
        //$mysqli=mysqli_connect('localhost','cactussegu','cactus123','cactussegu') or die("Database Error");
	//$sql="SELECT MA.NOME AS MARCA, MO.ID AS ID,  MO.NOME AS MODELO FROM MARCA MA INNER JOIN MODELO MO ON MA.ID = MO.MARCA WHERE MO.NOME LIKE '%$my_data%' ORDER BY MO.NOME";
        //$sql="SELECT MA.NOME AS MARCA, MO.NOME AS MODELO FROM MARCA MA INNER JOIN MODELO MO ON MA.ID = MO.MARCA WHERE MO.NOME LIKE  '%$my_data%' ORDER BY MO.NOME";
        $sql="SELECT marca.nome as marca, modelo.id as id, modelo.nome as modelo FROM marca, modelo WHERE marca.id = modelo.marca AND modelo.nome LIKE  '%$my_data%'";
	$result = mysqli_query($mysqli,$sql) or die(mysqli_error());
	
	if($result)
	{
		while($row=mysqli_fetch_array($result))
		{
			//echo $row['id']." - ".$row['marca']." - ".$row['modelo']."\n";
                    echo $row['modelo']."\n";
		}
	}
?>